//! @Author: DengLibin 榆霖
//! @Date:  2022-06-30 16:02:49
//! @Description: 
use std::fmt::Display;

use serde::{Deserialize, Serialize};


#[derive(Deserialize, Serialize, PartialEq, Eq, Clone)]
pub struct User {
    pub id: i64,//id
    pub deleted: bool, //是否删除
    pub create_time: Option<String>, //创建时间
    pub update_time: Option<String>, //更新时间
    pub create_by: i64, //创建人id
    pub update_by: i64, //更新人id
    pub user_login_name: String, // 登陆名
    pub name: String, //姓名
    pub phone_num: String, //手机号
    pub passwords: String, //登陆密码
    pub image_url: Option<String>, //头像
}

impl Display for User {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let creat_time = match &self.create_time {
            Some(c) => c.as_str(),
            None => ""
        };
        let update_time = match &self.update_time {
            Some(c) => c.as_str(),
            None => ""
        };
        let image_url = match &self.image_url {
            Some(c) => c.as_str(),
            None => ""
        };



        write!(
            f,
            "id:{}, deleted:{}, create_time:{}, update_time:{}, 
            create_by:{}, update_by:{}, user_login_name:{}, 
            name:{}, phone_num:{}, passwords:{}, image_url:{}",
            self.id, self.deleted, creat_time, update_time,
            self.create_by, self.update_by, self.user_login_name, self.name, 
            self.phone_num, self.passwords, image_url
        )
    }
}


